<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>企业广告乐币规则管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
        function findProvince(v) {
            $.ajax({
                type : "post",
                async : false,
                url : "${ctx}/sys/area/getAreaListByParentId",
                data : {
                    'pid' : v
                },
                dataType : "json",
                success : function(msg) {
                    $("#province").empty();
                    $("#city").empty();
                    $("#province").select2();
                    var $option2 = $("<option>").attr({
                        "value" :""
                    }).text("全部");
                    $("#province").append($option2);
                    if (msg.length > 0) {
                        for (var i = 0; i < msg.length; i++) {
                            var partId = msg[i].id;
                            var partName = msg[i].name;
                            var $option = $("<option>").attr({
                                "value" : partId
                            }).text(partName);
                            $("#province").append($option);
                        }

                        $("#province").change();

                    }
                },
                error : function(json) {
                    $.jBox.alert("网络异常！");
                }
            });
        }
        function findCity(v) {
            $.ajax({
                type : "post",
                async : false,
                url : "${ctx}/sys/area/getAreaListByParentId",
                data : {
                    'pid' : v
                },
                dataType : "json",
                success : function(msg) {

                    $("#city").empty();
                    $("#city").select2();
                    var $option2 = $("<option>").attr({
                        "value" :""
                    }).text("全部");
                    $("#city").append($option2);
                    if (msg.length > 0) {
                        for (var i = 0; i < msg.length; i++) {
                            var partId = msg[i].id;
                            var partName = msg[i].name;
                            var $option = $("<option>").attr({
                                "value" : partId
                            }).text(partName);
                            $("#city").append($option);
                        }

                        $("#city").change();

                    }
                },
                error : function(json) {
                    $.jBox.alert("网络异常！");
                }
            });
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/adv/hkEnterpriseAdvIntegralRule/">企业广告乐币规则列表</a></li>
		<li class="active"><a href="${ctx}/adv/hkEnterpriseAdvIntegralRule/form?id=${hkEnterpriseAdvIntegralRule.id}">企业广告乐币规则<shiro:hasPermission name="adv:hkEnterpriseAdvIntegralRule:edit">${not empty hkEnterpriseAdvIntegralRule.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="adv:hkEnterpriseAdvIntegralRule:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="hkEnterpriseAdvIntegralRule" action="${ctx}/adv/hkEnterpriseAdvIntegralRule/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<form:hidden path="enterpriseId"/>

		<div class="control-group">
			<label class="control-label">乐币类型：</label>
			<div class="controls">
				<form:select path="type" class="input-xlarge ">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('hk_adv_integral_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">数量：</label>
			<div class="controls">
				<form:input path="integral" htmlEscape="false" maxlength="11" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开始时间：</label>
			<div class="controls">
				<input name="beginDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${hkEnterpriseAdvIntegralRule.beginDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">结束时间：</label>
			<div class="controls">
				<input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${hkEnterpriseAdvIntegralRule.endDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">国家：</label>
			<div class="controls">
				<form:select path="country.id" id="country" class="input-medium required" onchange="findProvince(this.options[this.options.selectedIndex].value);">
					<form:option value="" label=""/>
					<form:options items="${countrys}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">省：</label>
			<div class="controls">
				<form:select path="province.id" id="province" class="input-medium" onchange="findCity(this.options[this.options.selectedIndex].value);">
					<form:option value="" label="全部"/>
					<form:options items="${provinces}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">市：</label>
			<div class="controls">
				<form:select path="city.id" id="city" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${citys}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="100" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="adv:hkEnterpriseAdvIntegralRule:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>